package cn.iocoder.yudao.module.api.product.spu.dto;

import com.fasterxml.jackson.annotation.JsonProperty;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;

import java.util.List;

/**
 * 适配 UNI-APP SKU 组件的产品 SPU 信息 Response DTO
 * <pre>
 * {
 *     "product_id": "1868467294336892929",
 *     "product": {
 *         "id": "1868467294336892929",
 *         "title": "贵阳肠旺面",
 *         "desc": "",
 *         "details": null,
 *         "product_category_id": "1868461731947409409",
 *         "cover": "http://192.168.5.55:48080/admin-api/infra/file/24/get/681cbe2922e0f84192e0cc1f6fa789ca530ed638fe447e0794623486ebb4c5f0.jpg",
 *         "carousel_imgs": [
 *             "http://192.168.5.55:48080/admin-api/infra/file/24/get/681cbe2922e0f84192e0cc1f6fa789ca530ed638fe447e0794623486ebb4c5f0.jpg"
 *         ],
 *         "price": 1200,
 *         "market_price": 0,
 *         "vip_price": 1000,
 *         "stock": 3996,
 *         "sales_count": 0
 *     },
 *     "sku_list": [
 *         {
 *             "_id": "1869932484572110850",
 *             "goods_id": "1868467294336892929",
 *             "goods_name": "贵阳肠旺面",
 *             "price": 1300,
 *             "group_price": 1200,
 *             "snap_price": 0,
 *             "image": "",
 *             "stock": 999,
 *             "sku_name_arr": [
 *                 "大碗",
 *                 "麻辣"
 *             ]
 *         },
 *         {
 *             "_id": "1869932484643414018",
 *             "goods_id": "1868467294336892929",
 *             "goods_name": "贵阳肠旺面",
 *             "price": 1200,
 *             "group_price": 1200,
 *             "snap_price": 0,
 *             "image": "",
 *             "stock": 999,
 *             "sku_name_arr": [
 *                 "小碗",
 *                 "麻辣"
 *             ]
 *         },
 *         {
 *             "_id": "1869932484697939969",
 *             "goods_id": "1868467294336892929",
 *             "goods_name": "贵阳肠旺面",
 *             "price": 1300,
 *             "group_price": 1200,
 *             "snap_price": 0,
 *             "image": "",
 *             "stock": 999,
 *             "sku_name_arr": [
 *                 "大碗",
 *                 "清汤"
 *             ]
 *         },
 *         {
 *             "_id": "1869932484697939970",
 *             "goods_id": "1868467294336892929",
 *             "goods_name": "贵阳肠旺面",
 *             "price": 1200,
 *             "group_price": 1200,
 *             "snap_price": 0,
 *             "image": "",
 *             "stock": 999,
 *             "sku_name_arr": [
 *                 "小碗",
 *                 "清汤"
 *             ]
 *         }
 *     ],
 *     "spec_list": [
 *         {
 *             "name": "份量",
 *             "list": [
 *                 {
 *                     "name": "大碗"
 *                 },
 *                 {
 *                     "name": "小碗"
 *                 }
 *             ]
 *         },
 *         {
 *             "name": "口味",
 *             "list": [
 *                 {
 *                     "name": "麻辣"
 *                 },
 *                 {
 *                     "name": "清汤"
 *                 }
 *             ]
 *         }
 *     ]
 * }
 * </pre>
 * <pre>
 * {
 *     "url": "https://sjyaiqybxtx.com/api/goods/36/details",
 *     "status": "SUCCESS",
 *     "code": 200,
 *     "message": "OK",
 *     "data": {
 *         "id": 36,
 *         "sort": 1,
 *         "goods_type": 10,
 *         "name": "测试多规格",
 *         "keyword": "啄木鸟|卫衣|男衣",
 *         "category_id": 3,
 *         "zone_id": 2,
 *         "sku": "{\"attrs\":{\"\\u989c\\u8272\":[\"\\u84dd\\u8272\",\"\\u6a59\\u8272\"],\"\\u5305\\u88c5\":[\"\\u7cbe\\u7f8e\",\"\\u793c\\u76d2\"]},\"sku\":[{\"\\u989c\\u8272\":\"\\u84dd\\u8272\",\"\\u5305\\u88c5\":\"\\u7cbe\\u7f8e\",\"pic\":[{\"short_url\":\"sku\\/tEeYNxQ50sdZ39LnXJaLCWnZd7DXfyXVE1LJtqDm.png\",\"full_url\":\"http:\\/\\/192.168.5.36:92\\/\\/uploads\\/sku\\/tEeYNxQ50sdZ39LnXJaLCWnZd7DXfyXVE1LJtqDm.png\"}],\"stock\":\"99\",\"price\":\"5990\",\"price_1\":\"5990\",\"price_2\":\"4880\",\"price_3\":\"4300\",\"price_4\":\"2990\",\"price_5\":\"2590\",\"id\":24},{\"\\u989c\\u8272\":\"\\u84dd\\u8272\",\"\\u5305\\u88c5\":\"\\u793c\\u76d2\",\"pic\":[{\"short_url\":\"sku\\/hUEU1DL2i1S3F1MCiqgMC5zm20W5icQivNar9EcK.png\",\"full_url\":\"http:\\/\\/192.168.5.36:92\\/\\/uploads\\/sku\\/hUEU1DL2i1S3F1MCiqgMC5zm20W5icQivNar9EcK.png\"}],\"stock\":\"99\",\"price\":\"599\",\"price_1\":\"599\",\"price_2\":\"488\",\"price_3\":\"430\",\"price_4\":\"299\",\"price_5\":\"259\",\"id\":25},{\"\\u989c\\u8272\":\"\\u6a59\\u8272\",\"\\u5305\\u88c5\":\"\\u7cbe\\u7f8e\",\"pic\":[{\"short_url\":\"sku\\/IMMBVBZ3u6tI1dgvVGMJj06DwIIEeRJYGs5bw8vC.png\",\"full_url\":\"http:\\/\\/192.168.5.36:92\\/\\/uploads\\/sku\\/IMMBVBZ3u6tI1dgvVGMJj06DwIIEeRJYGs5bw8vC.png\"}],\"stock\":\"99\",\"price\":\"5990\",\"price_1\":\"5990\",\"price_2\":\"4880\",\"price_3\":\"4300\",\"price_4\":\"2990\",\"price_5\":\"2590\",\"id\":26},{\"\\u989c\\u8272\":\"\\u6a59\\u8272\",\"\\u5305\\u88c5\":\"\\u793c\\u76d2\",\"pic\":[{\"short_url\":\"sku\\/NPV0hAjQ1IwJeP9KwB1y3F1BPGx5UxPjtkd3VKot.png\",\"full_url\":\"http:\\/\\/192.168.5.36:92\\/\\/uploads\\/sku\\/NPV0hAjQ1IwJeP9KwB1y3F1BPGx5UxPjtkd3VKot.png\"}],\"stock\":\"99\",\"price\":\"599\",\"price_1\":\"599\",\"price_2\":\"488\",\"price_3\":\"430\",\"price_4\":\"299\",\"price_5\":\"259\",\"id\":27}]}",
 *         "images": "[\"images\\/e2fe843023814efbf60b43a1be3f1f53.jpg\"]",
 *         "price": "599.00",
 *         "delivery_id": 3,
 *         "sub_title": null,
 *         "short_title": null,
 *         "detail": null,
 *         "is_sale": 1,
 *         "is_open_spec": 1,
 *         "month_sale_count": 0,
 *         "sale_count": 0,
 *         "is_gift_point": 0,
 *         "gift_point": "0.00",
 *         "distributor_one_amount": "0.00",
 *         "distributor_two_amount": "0.00",
 *         "deduction_point": 0,
 *         "created_at": "2024-05-30 18:12:00",
 *         "updated_at": "2024-07-01 15:35:03",
 *         "images_format": [
 *             "https://sjyaiqybxtx.com//uploads/images/e2fe843023814efbf60b43a1be3f1f53.jpg"
 *         ],
 *         "skus": {
 *             "id": 36,
 *             "name": "测试多规格",
 *             "image": "https://sjyaiqybxtx.com//uploads/images/e2fe843023814efbf60b43a1be3f1f53.jpg",
 *             "list": [
 *                 {
 *                     "id": 24,
 *                     "goods_id": 36,
 *                     "cover": "sku/tEeYNxQ50sdZ39LnXJaLCWnZd7DXfyXVE1LJtqDm.png",
 *                     "cover_format": "https://sjyaiqybxtx.com//uploads/",
 *                     "price": "5990.00",
 *                     "stock": null
 *                 },
 *                 {
 *                     "id": 25,
 *                     "goods_id": 36,
 *                     "cover": "sku/hUEU1DL2i1S3F1MCiqgMC5zm20W5icQivNar9EcK.png",
 *                     "cover_format": "https://sjyaiqybxtx.com//uploads/",
 *                     "price": "599.00",
 *                     "stock": null
 *                 },
 *                 {
 *                     "id": 26,
 *                     "goods_id": 36,
 *                     "cover": "sku/IMMBVBZ3u6tI1dgvVGMJj06DwIIEeRJYGs5bw8vC.png",
 *                     "cover_format": "https://sjyaiqybxtx.com//uploads/",
 *                     "price": "5990.00",
 *                     "stock": null
 *                 },
 *                 {
 *                     "id": 27,
 *                     "goods_id": 36,
 *                     "cover": "sku/NPV0hAjQ1IwJeP9KwB1y3F1BPGx5UxPjtkd3VKot.png",
 *                     "cover_format": "https://sjyaiqybxtx.com//uploads/",
 *                     "price": "599.00",
 *                     "stock": null
 *                 }
 *             ],
 *             "specs": []
 *         },
 *         "is_collect": 0,
 *         "is_buy": 0,
 *         "freight_setting": null,
 *         "min_price": "599.00",
 *         "stock": 98,
 *         "line_price": "5990.00",
 *         "sku_list": [
 *             {
 *                 "id": 24,
 *                 "goods_id": 36,
 *                 "spec_sku_id": "59_56",
 *                 "image": "sku/tEeYNxQ50sdZ39LnXJaLCWnZd7DXfyXVE1LJtqDm.png",
 *                 "price": "5990.00",
 *                 "price_1": "5990.00",
 *                 "price_2": "4880.00",
 *                 "price_3": "4300.00",
 *                 "price_4": "2990.00",
 *                 "price_5": "2590.00",
 *                 "stock": 98,
 *                 "goods_sales": 0,
 *                 "goods_weight": 0,
 *                 "distributor_one_amount": null,
 *                 "distributor_two_amount": null,
 *                 "created_at": "2024-05-30 18:12:00",
 *                 "updated_at": "2024-06-01 15:18:23",
 *                 "format_image": "https://sjyaiqybxtx.com//uploads/sku/tEeYNxQ50sdZ39LnXJaLCWnZd7DXfyXVE1LJtqDm.png",
 *                 "spec_value_ids": [
 *                     "59",
 *                     "56"
 *                 ],
 *                 "goods_props": [
 *                     {
 *                         "group": {
 *                             "name": "颜色",
 *                             "id": 39
 *                         },
 *                         "value": {
 *                             "name": "蓝色",
 *                             "id": 59
 *                         }
 *                     },
 *                     {
 *                         "group": {
 *                             "name": "包装",
 *                             "id": 37
 *                         },
 *                         "value": {
 *                             "name": "精美",
 *                             "id": 56
 *                         }
 *                     }
 *                 ],
 *                 "line_price": "5990.00",
 *                 "grade_price": "5990.00"
 *             },
 *             {
 *                 "id": 25,
 *                 "goods_id": 36,
 *                 "spec_sku_id": "59_61",
 *                 "image": "sku/hUEU1DL2i1S3F1MCiqgMC5zm20W5icQivNar9EcK.png",
 *                 "price": "599.00",
 *                 "price_1": "599.00",
 *                 "price_2": "488.00",
 *                 "price_3": "430.00",
 *                 "price_4": "299.00",
 *                 "price_5": "259.00",
 *                 "stock": 92,
 *                 "goods_sales": 0,
 *                 "goods_weight": 0,
 *                 "distributor_one_amount": null,
 *                 "distributor_two_amount": null,
 *                 "created_at": "2024-05-30 18:12:00",
 *                 "updated_at": "2024-06-01 14:38:53",
 *                 "format_image": "https://sjyaiqybxtx.com//uploads/sku/hUEU1DL2i1S3F1MCiqgMC5zm20W5icQivNar9EcK.png",
 *                 "spec_value_ids": [
 *                     "59",
 *                     "61"
 *                 ],
 *                 "goods_props": [
 *                     {
 *                         "group": {
 *                             "name": "颜色",
 *                             "id": 39
 *                         },
 *                         "value": {
 *                             "name": "蓝色",
 *                             "id": 59
 *                         }
 *                     },
 *                     {
 *                         "group": {
 *                             "name": "包装",
 *                             "id": 37
 *                         },
 *                         "value": {
 *                             "name": "礼盒",
 *                             "id": 61
 *                         }
 *                     }
 *                 ],
 *                 "line_price": "599.00",
 *                 "grade_price": "599.00"
 *             },
 *             {
 *                 "id": 26,
 *                 "goods_id": 36,
 *                 "spec_sku_id": "78_56",
 *                 "image": "sku/IMMBVBZ3u6tI1dgvVGMJj06DwIIEeRJYGs5bw8vC.png",
 *                 "price": "5990.00",
 *                 "price_1": "5990.00",
 *                 "price_2": "4880.00",
 *                 "price_3": "4300.00",
 *                 "price_4": "2990.00",
 *                 "price_5": "2590.00",
 *                 "stock": 98,
 *                 "goods_sales": 0,
 *                 "goods_weight": 0,
 *                 "distributor_one_amount": null,
 *                 "distributor_two_amount": null,
 *                 "created_at": "2024-05-30 18:12:00",
 *                 "updated_at": "2024-05-31 18:52:26",
 *                 "format_image": "https://sjyaiqybxtx.com//uploads/sku/IMMBVBZ3u6tI1dgvVGMJj06DwIIEeRJYGs5bw8vC.png",
 *                 "spec_value_ids": [
 *                     "78",
 *                     "56"
 *                 ],
 *                 "goods_props": [
 *                     {
 *                         "group": {
 *                             "name": "颜色",
 *                             "id": 39
 *                         },
 *                         "value": {
 *                             "name": "橙色",
 *                             "id": 78
 *                         }
 *                     },
 *                     {
 *                         "group": {
 *                             "name": "包装",
 *                             "id": 37
 *                         },
 *                         "value": {
 *                             "name": "精美",
 *                             "id": 56
 *                         }
 *                     }
 *                 ],
 *                 "line_price": "5990.00",
 *                 "grade_price": "5990.00"
 *             },
 *             {
 *                 "id": 27,
 *                 "goods_id": 36,
 *                 "spec_sku_id": "78_61",
 *                 "image": "sku/NPV0hAjQ1IwJeP9KwB1y3F1BPGx5UxPjtkd3VKot.png",
 *                 "price": "599.00",
 *                 "price_1": "599.00",
 *                 "price_2": "488.00",
 *                 "price_3": "430.00",
 *                 "price_4": "299.00",
 *                 "price_5": "259.00",
 *                 "stock": 99,
 *                 "goods_sales": 0,
 *                 "goods_weight": 0,
 *                 "distributor_one_amount": null,
 *                 "distributor_two_amount": null,
 *                 "created_at": "2024-05-30 18:12:00",
 *                 "updated_at": "2024-05-30 18:12:00",
 *                 "format_image": "https://sjyaiqybxtx.com//uploads/sku/NPV0hAjQ1IwJeP9KwB1y3F1BPGx5UxPjtkd3VKot.png",
 *                 "spec_value_ids": [
 *                     "78",
 *                     "61"
 *                 ],
 *                 "goods_props": [
 *                     {
 *                         "group": {
 *                             "name": "颜色",
 *                             "id": 39
 *                         },
 *                         "value": {
 *                             "name": "橙色",
 *                             "id": 78
 *                         }
 *                     },
 *                     {
 *                         "group": {
 *                             "name": "包装",
 *                             "id": 37
 *                         },
 *                         "value": {
 *                             "name": "礼盒",
 *                             "id": 61
 *                         }
 *                     }
 *                 ],
 *                 "line_price": "599.00",
 *                 "grade_price": "599.00"
 *             }
 *         ],
 *         "specList": [
 *             {
 *                 "spec_id": 39,
 *                 "spec_name": "颜色",
 *                 "key": 0,
 *                 "valueList": [
 *                     {
 *                         "key": 0,
 *                         "groupKey": 0,
 *                         "spec_value_id": 59,
 *                         "spec_value": "蓝色"
 *                     },
 *                     {
 *                         "key": 1,
 *                         "groupKey": 0,
 *                         "spec_value_id": 78,
 *                         "spec_value": "橙色"
 *                     }
 *                 ]
 *             },
 *             {
 *                 "spec_id": 37,
 *                 "spec_name": "包装",
 *                 "key": 1,
 *                 "valueList": [
 *                     {
 *                         "key": 0,
 *                         "groupKey": 1,
 *                         "spec_value_id": 56,
 *                         "spec_value": "精美"
 *                     },
 *                     {
 *                         "key": 1,
 *                         "groupKey": 1,
 *                         "spec_value_id": 61,
 *                         "spec_value": "礼盒"
 *                     }
 *                 ]
 *             }
 *         ]
 *     }
 * }
 * </pre>
 *
 * @author 山野羡民
 * @since 2024/03/25,2024/12/09
 */
@SuppressWarnings("JavadocLinkAsPlainText")
@Data
public class ProductSpuForUniAppRespDTO {
    @Schema(name = "SKU 列表")
    @JsonProperty("sku_list")
    private List<Sku> skuList;
    @Schema(name = "规格 列表")
    @JsonProperty("spec_list")
    private List<SpecGroup> specList;

    @Data
    public static class Sku {
        @Schema(name = "SKU编号")
        @JsonProperty("_id")
        private Long id;
        @Schema(name = "SPU编号")
        @JsonProperty("goods_id")
        private Long goodsId;
        @Schema(name = "产品名称")
        @JsonProperty("goods_name")
        private String goodsName;
        @Schema(name = "销售价格")
        @JsonProperty("price")
        private Integer price;
        @Schema(name = "最低价格（多规格情况下）")
        @JsonProperty("group_price")
        private Integer groupPrice;
        @Schema(name = "封面图片")
        @JsonProperty("image")
        private String image;
        @Schema(name = "库存")
        @JsonProperty("stock")
        private Integer stock;
        @Schema(name = "规格项编号")
        @JsonProperty("spec_value_ids")
        private List<Long> specValueIds; // 前端非要让增加该字段来判断获取所选的SKU，其实用`skuNameArr`就行
        @Schema(name = "规格项列表")
        @JsonProperty("sku_name_arr")
        private List<String> skuNameArr;
    }

    @Data
    public static class SpecGroup {
        @Schema(name = "规格项名称")
        @JsonProperty("name")
        private String name;
        @Schema(name = "规格值列表")
        @JsonProperty("list")
        private List<SpecVal> list;
    }

    @Data
    public static class SpecVal {
        @Schema(name = "规格值编号")
        @JsonProperty("id")
        private Long id;
        @Schema(name = "规格值名称")
        @JsonProperty("name")
        private String name;
    }

}
